Create websites with TailwindCSS
Start building the next great SAAS
Alpine & Tailwind UI Library
Plug'n Play Authentication for Laravel
Create website designs with AI
Blog platform for developers
Build a simple static website
21-day program to build a SAAS
Upgrade your account to get access to all content.
Created on October 5th, 2016
Using DateTime in PHP can sometimes be a hassle. Luckily enough there is an awesome PHP library that we can use called Carbon. Carbon allows us to easily manipulate dates using PHP.
Now something as easy as getting yesterday's date in a nicely formatted string can be as easy as this:
<?php
$yesterday = Carbon::yesterday()->toFormattedDateString();
echo $yesterday; // Oct 4, 2016
If you had been working with javascript in the past and you are familiar with moment.js, you may have been wondering to yourself... "I wish dealing with DateTime in PHP was as easy as that", well now it is. Carbon is definitely a library you will want to include in all your PHP applications and if you are using Laravel you'll have the convenience of using this package out of the box :)
577
Comments (0)